package com.xwj.dao;

import com.xwj.domain.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * @author xwj
 * @date 2020/11/10
 */
@Mapper
@Repository
public interface OrderMapper {
    /**
     * 新建订单
     *
     * @param order
     */
    @Insert("insert into t_order(user_id,product_id,count,money,status) values(#{userId},#{productId},#{count},#{money},0)")
    void create(Order order);

    /**
     * 修改订单状态
     *
     * @param userId
     * @param status
     */
    @Update("update t_order set status = 1 where user_id=#{userId} and status = #{status}")
    void update(@Param("userId") Long userId, @Param("status") Integer status);
}
